// 环境类型枚举
export type EnvironmentType = 'development' | 'test' | 'preview' | 'production' | 'custom';

// 环境接口
export interface Environment {
  id: string;
  name: string;
  type: EnvironmentType;
  hosts: string[];
  hostsText?: string; // 用于表单输入的文本形式，每行一个host
  isActive: boolean;
  description?: string;
}

// 项目接口
export interface Project {
  id: string;
  name: string;
  description: string;
  groupId: string;
  environments: Environment[];
  createdAt: string;
  updatedAt: string;
}

// 项目分组接口
export interface ProjectGroup {
  id: string;
  name: string;
  createdAt: string;
  updatedAt: string;
}

// API响应基础接口
export interface ApiResponse<T = any> {
  success: boolean;
  data?: T;
  message?: string;
}

// 环境操作响应数据
export interface EnvironmentOperationData {
  environment: Environment;
  rulesUpdated: boolean;
  timestamp: string;
  responseTime: number;
  activeHosts?: string[];
  deactivatedHosts?: string[];
  forceRefresh: boolean;
  error?: string;
}

// 环境操作响应
export interface EnvironmentOperationResponse extends ApiResponse<EnvironmentOperationData> {}

// 搜索和筛选状态
export interface FilterState {
  searchKeyword: string;
  selectedGroupIds: string[];
}

// 管理员权限状态
export interface AuthState {
  isAdmin: boolean;
  loginClickCount: number;
}

// 项目表单数据
export interface ProjectFormData {
  name: string;
  description: string;
  groupId: string;
  environments: Omit<Environment, 'id' | 'isActive'>[];
}

// 分组表单数据
export interface GroupFormData {
  name: string;
}

// 环境显示组件props
export interface EnvironmentSwitchProps {
  environment: Environment;
  projectId: string;
  disabled?: boolean;
}

// 项目卡片组件props
export interface ProjectCardProps {
  project: Project;
  isAdmin: boolean;
}
